<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2000/REC-xhtml1-200000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>symfony reference card</title>
<link rel="stylesheet" type="text/css" href="refcard.css" />
</head>
<body>

<h1>&raquo;&nbsp;symfony reference card 1.0&nbsp;&laquo;</h1>

<!-- column start -->
<div class="col">

<div class="subcol">
<h2>sfAction &lt; Action</h2>
<div class="content">

<h3>Returns</h3>
-&gt;<span class="method">forward</span>($module, $action), 
-&gt;<span class="method">render_text</span>($text), 
<span class="method">sfView::SUCCESS</span>

<h3>Shortcuts</h3>
-&gt;<span class="method">getController</span>(), 
-&gt;<span class="method">getUser</span>(), 
-&gt;<span class="method">getRequest</span>(), 
-&gt;<span class="method">getRequestParameter</span>($name)()

<h3>Template variables</h3>
-&gt;<span class="method">setVar</span>(), 
-&gt;<span class="method">setVars</span>(), 
-&gt;<span class="method">removeVar</span>(), 
-&gt;<span class="method">hasVar</span>(), 
-&gt;<span class="method">getVars</span>(), 
-&gt;<span class="method">clearVars</span>()

<h3>Models an helpers</h3>
-&gt;<span class="method">useModel(s)</span>(), 
-&gt;<span class="method">useHelper(s)</span>()

<h3>Authentication</h3>
-&gt;<span class="method">setSecure</span>(S|L|A), 
-&gt;<span class="method">checkCredential</span>($crendentials, S|L|A)

<h3>Cache</h3>
-&gt;<span class="method">setCache</span>($time, S|L|A), 
-&gt;<span class="method">cacheExists</span>(), 
-&gt;<span class="method">isCached</span>()
<br /><span class="method">sfView::ALL</span> (toutes les actions)

<h3>Introspection</h3>
-&gt;<span class="method">getModuleName</span>(), 
-&gt;<span class="method">getActionName</span>()

<h3>Templates</h3>
-&gt;<span class="method">setHasLayout</span>($boolean), 
-&gt;<span class="method">hasLayout</span>()
-&gt;<span class="method">setLayout</span>($name)
-&gt;<span class="method">setTemplate</span>($name)

</div>
</div>

<div class="subcol">
<h2>sfUser &lt; SecurityUser &lt; User &lt; ParameterHolder</h2>
<div class="content">

<h3>Authentication</h3>
-&gt;<span class="method">isAuthenticated</span>(), 
-&gt;<span class="method">setAuthenticated</span>(B)

<h3>Droits</h3>
-&gt;<span class="method">addCredentials</span>(S|L|A), 
-&gt;<span class="method">hasCredential</span>(S|L|A), 
-&gt;<span class="method">clearCredentials</span>(), 
-&gt;<span class="method">removeCredential</span>(S)

<h3>Language</h3>
-&gt;<span class="method">setCulture</span>(code ISO), 
-&gt;<span class="method">getCulture</span>()

</div>
</div>

<div class="subcol">
<h2>WebRequest &lt; Request &lt; ParameterHolder</h2>
<div class="content">
For access to parameters, cf. ParameterHolder class.

<h3>Form validation</h3>
-&gt;<span class="method">getError</span>($name), 
-&gt;<span class="method">getErrors</span>(), 
-&gt;<span class="method">hasError</span>($name), 
-&gt;<span class="method">hasErrors</span>(), 
-&gt;<span class="method">setError</span>($name, $message), 
-&gt;<span class="method">getErrorNames</span>(), -&gt;<span class="method">removeError</span>($name)

<h3>Files</h3>
-&gt;<span class="method">moveFile</span>($name, $file, [$fileMode = 0666], [$create = true], [$dirMode = 0777]), 
-&gt;<span class="method">hasFileError</span>($name), 
-&gt;<span class="method">hasFileErrors</span>(), 
-&gt;<span class="method">getFileName</span>($name), 
-&gt;<span class="method">getFiles</span>(), 
-&gt;<span class="method">hasFile</span>($name), 
-&gt;<span class="method">hasFiles</span>(), 
-&gt;<span class="method">getFile</span>($name), -&gt;<span class="method">getFileType</span>($name), -&gt;<span class="method">getFileError</span>($name), -&gt;<span class="method">getFileNames</span>(), -&gt;<span class="method">getFilePath</span>($name), -&gt;<span class="method">getFileSize</span>($name)

<h3>Attributes</h3>
-&gt;<span class="method">getAttribute</span>($name), 
-&gt;<span class="method">getAttributeNames</span>(), 
-&gt;<span class="method">hasAttribute</span>($name), 
-&gt;<span class="method">setAttribute</span>($name, $value), 
-&gt;<span class="method">removeAttribute</span>($name), 
-&gt;<span class="method">clearAttributes</span>()

</div>
</div>

<div class="subcol">
<h2>ParameterHolder</h2>
<div class="content">
-&gt;<span class="method">clearParameters</span>(), 
-&gt;<span class="method">getParameter</span>($name, [$default]), 
-&gt;<span class="method">getParameterNames</span>(), 
-&gt;<span class="method">getParameters</span>(), 
-&gt;<span class="method">hasParameter</span>($name), 
-&gt;<span class="method">removeParameter</span>($name), 
-&gt;<span class="method">setParameter</span>($name, $value), 
-&gt;<span class="method">setParameters</span>($parameters), 
-&gt;<span class="method">setParameterByRef</span>($name, $value), 
-&gt;<span class="method">setParametersByRef</span>(&$parameters)

</div>
</div>

<!-- column end -->
</div>

<!-- column start -->
<div class="col">

<div class="subcol">
<h2>Validators</h2>
<div class="content">
<ul>
<li><span class="method">NumberValidator</span> [max], [max_error], [min], [min_error], [nan_error], [type], [type_error]</li>
<li><span class="method">RegexValidator</span> pattern, [match], [match_error]</li>
<li><span class="method">StringValidator</span> [insensitive], [max], [max_error], [min], [min_error], [values], [values_errors]</li>
<li><span class="method">sfEmailValidator</span> [email_error]</li>
<li><span class="method">sfHtmlValidator</span> [html_error]</li>
</ul>

</div>
</div>

<div class="subcol">
<h2>schema.xml</h2>
<div class="content">

<pre>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;database name="DATABASE_NAME" defaultIdMethod="native"&gt;
&nbsp;&lt;table name="TABLE_NAME"&gt;
&nbsp;&nbsp;&nbsp;&lt;column name="COLUMN_NAME" [phpName="PHP_NAME"]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type="(integer|varchar|longvarchar|date|boolean)"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[required="true"] [defaultValue=""]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[primaryKey="true"] [autoIncrement="true"] /&gt;
&nbsp;&nbsp;&lt;foreign-key foreignTable="TABLE_BIS_NAME"&gt;
&nbsp;&nbsp;&nbsp;&lt;reference local="id_TABLE_BIS_NAME" foreign="id"/&gt;
&nbsp;&nbsp;&lt;/foreign-key&gt;
&nbsp;&lt;/table&gt;
&lt;/database&gt;
</pre>

</div>
</div>

<div class="subcol">
<h2>Generated object classes</h2>
<div class="content">

<h3>Object.class.php</h3>
<ul>
<li>-&gt;<span class="method">get[PHP_COLUMN]</span>(), -&gt;<span class="method">set[PHP_COLUMN]</span>($value)</li>
<li>-&gt;<span class="method">add[RELATED COLUMN]</span>($obj), -&gt;<span class="method">get[RELATED COLUMN]</span>()</li>
<li>-&gt;<span class="method">getByName</span>($name), -&gt;<span class="method">setByName</span>($name, $value)</li>
<li>-&gt;<span class="method">save</span>(), -&gt;<span class="method">delete</span>(), -&gt;<span class="method">copy</span>()</li>
</ul>

<h3>ObjectPeer.class.php</h3>
$c : Criteria
<ul>
<li>::<span class="method">doCount</span>($c), ::<span class="method">doSelectOne</span>($c), ::<span class="method">doDeleteAll</span>(), ::<span class="method">doSelect</span>($c)</li>
<li>::<span class="method">retrieveByPK</span>($pk)</li>
<li>::<span class="method">doSelectJoin[JOIN_COLUMN]</span>($c), ::<span class="method">doSelectJoinAll</span>($c)</li>
</ul>

<h3>Criteria</h3>
<ul>
<li>-&gt;<span class="method">setLimit</span>($limit)</li>
<li>-&gt;<span class="method">setOffset</span>($offset)</li>
<li>-&gt;<span class="method">addGroupByColumn</span>($groupBy), -&gt;<span class="method">clearGroupByColumns</span>()</li>
<li>-&gt;<span class="method">add(Asc|Desc)endingOrderByColumn</span>($name), -&gt;<span class="method">clearOrderByColumns</span>()</li>
</ul>

</div>
</div>

<div class="subcol">
<h2>Exemple Action</h2>
<div class="content">

<pre>
class mainActions extends sfActions
{
  public function preExecute()
  {
    $this->setCache(2 * 86400, 'Index', 'Show');
    $this->useModels('person', 'company');
    $this->useHelpers('Wiki', 'List');
  }

  public function executeIndex()
  {
    $this->setVar('persons', PersonPeer::doSelect());
    return sfView::SUCCESS;
  }
}
</pre>

</div>
</div>

<div class="subcol">
<h2>Command line</h2>
<div class="content">

<h3>Administration</h3>
<ul>
<li><span class="method">clear-cache</span> cache erase all</li>
<li><span class="method">sync-prod[-dry]</span> synchronisation (-dry test)</li>
</ul>

<h3>Generation</h3>
<ul>
<li><span class="method">init-project</span> projet creation</li>
<li><span class="method">propel-build-model</span> object model generation</li>
<li><span class="method">propel-generate-crud</span> back-office generation</li>
</ul>

</div>
</div>

<!-- column end -->
</div>

<!-- column start -->
<div class="col">

<div class="subcol">
<h2>Template helpers</h2>
<div class="content">
$options : additional html attributes, in hash or string syntax<br />
<span class="method">Array('class' => 'myclass', 'id' => 12, 'style' => 'width:100px' )</span><br />
<span class="method">'class=myclass id=12 style=width:100px'</span>

<h3>URL</h3>
<ul>
<li><span class="method">url_for</span>($url, [absolute=true])</li>
<li><span class="method">link_to</span>($name, $url, [$options])</li>
</ul>
$url: module/action?param=value or @rule?param=value

<h3>Form</h3>
<ul>
<li><span class="method">form_tag</span>($url, [$options])</li>
<li><span class="method">input_tag</span>($name, [$value], [$options])</li>
<li>same for <span class="method">input_hidden_tag</span>, <span class="method">input_password_tag</span>, <span class="method">textarea_tag</span></li>
<li><span class="method">select_tag</span>($name, [$option_tags], [$options])</li>
<li><span class="method">options_for_select</span>($options, [$selected])</li>
<li><span class="method">input_file_tag</span>($name, [$options])</li>
<li><span class="method">checkbox_tag</span>($name, [$value = 1], [$checked = false], [$options])</li>
<li><span class="method">radiobutton_tag</span>($name, $value, [$checked = false], [$options])</li>
<li><span class="method">submit_tag</span>($value, [$options])</li>
</ul>

<h3>Assets</h3>
<ul>
<li><span class="method">auto_discovery_link_tag</span>([$type], [$options])</li>
<li><span class="method">javascript_tag</span>(S|L|A) by default in js/ and .js</li>
<li><span class="method">image_path</span>($source) by default in images/ and .png</li>
<li><span class="method">image_tag</span>($source, [$options])</li>
</ul>

<h3>I18N</h3>
<ul>
<li><span class="method">__</span>($text, [$culture])</li>
</ul>

<h3>Templates</h3>
<ul>
<li><span class="method">include_partial</span>($name, [$vars]) inclusion template 'name', 'module/name' ou 'global/name'</li>
</ul>

<h3>Text</h3>
<ul>
<li><span class="method">truncate_text</span>($text, $length = 30, $truncate_string = '...')</li>
<li><span class="method">highlight_text</span>($text, $phrase, [$highlighter]) classe 'highlight' par défaut</li>
<li><span class="method">excerpt_text</span>($text, $phrase, $radius = 100, $excerpt_string = '...')</li>
<li><span class="method">simple_format_text</span>($text)</li>
<li><span class="method">auto_link_text</span>($text, $link = 'all')</li>
<li><span class="method">strip_links_text</span>($text)</li>
</ul>

<h3>Date</h3>
<ul>
<li><span class="method">format_date</span>($timestamp, [$culture])</li>
<li><span class="method">distance_of_time_in_words</span>($from_timestamp, $to_timestamp, [$include_seconds])</li>
<li><span class="method">time_ago_in_words</span>($from_timestamp, [$include_seconds])</li>
</ul>

<h3>Partial cache</h3>
<ul>
<li><span class="method">cache</span>($cache_time = 3600)</li>
<li><span class="method">cache_save</span>
<br />&lt;?php if (!cache()): ?&gt;... HTML ...&lt;?php cache_save() ?&gt;&lt;?php endif ?&gt;
</li>
</ul>

<h3>Javascript</h3>
<ul>
<li><span class="method">link_to_function</span>($name, $function, [$html_options])<br />link_to_function(image_tag("delete"), "if confirm('Really?'){ do_delete(); }")</li>
<li><span class="method">link_to_remote</span>($name, [$options], [$html_options])</li>
<li><span class="method">form_remote_tag([$options])</span></li>
<li><span class="method">remote_function</span>($options)</li>
<li><span class="method">observe_field</span>($field_id, [$options])</li>
<li><span class="method">observe_form</span>($form_id, [$options])</li>
<li><span class="method">escape_javascript</span>($javascript])</li>
</ul>

<h3>Object</h3>
$object represents the object (Propel)
<br />$column represents the column name ($object->get$column())
<br />unique signature: ($object, $column, [$options], [$value])
<span class="method">object_plain</span>, 
<span class="method">object_textarea_tag</span>, 
<span class="method">object_image_tag</span>, 
<span class="method">object_date_tag</span>, 
<span class="method">object_input_password_tag</span>, 
<span class="method">object_select_tag</span>, 
<span class="method">object_input_hidden_tag</span>, 
<span class="method">object_input_tag</span>, 
<span class="method">object_checkbox_tag</span>

</div>
</div>

<!-- column end -->
</div>

<!-- column start -->
<div class="col">

<div class="minisubcol">
<h2>Tree structure</h2>
<div class="content">

<ul>
<li><div style="float: right">[SF_ROOT_DIR]</div>/</li>
<li><div style="float: right">[SF_APP_DIR]</div>apps/</li>
<li><div style="float: right">x n applications</div>&nbsp;&nbsp;[APP]/</li>
<li><div style="float: right">[SF_MESSAGES_DIR]</div>&nbsp;&nbsp;&nbsp;&gt;&nbsp;i18n/</li>

<li>&nbsp;&nbsp;&nbsp;&gt;&nbsp;lib/</li>
<li>&nbsp;&nbsp;&nbsp;&gt;&nbsp;config/</li>
<li>&nbsp;&nbsp;&nbsp;&gt;&nbsp;i18n/</li>
<li>&nbsp;&nbsp;&nbsp;&gt;&nbsp;lib/</li>
<li>&nbsp;&nbsp;&nbsp;&gt;&nbsp;modules/</li>
<li><div style="float: right">x n modules</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;[MODULE]/</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;actions/</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;Actions.class.php</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;config/</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;lib/</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;templates/</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;IndexSuccess.php</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;validate/</li>
<li>&nbsp;&nbsp;&nbsp;&gt;&nbsp;templates/</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;layout.php</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;error.php</li>
<li><div style="float: right"></div>batch/</li>
<li><div style="float: right">[MO_CACHE_DIR]</div>cache/</li>
<li>&nbsp;&gt;&nbsp;[APP]/</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;[ENV]/</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;config/</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;template/</li>
<li>config/</li>
<li>&nbsp;&nbsp;&gt;&nbsp;build.properties</li>
<li>&nbsp;&nbsp;&gt;&nbsp;rsync_exclude.txt</li>
<li>&nbsp;&nbsp;&gt;&nbsp;schema.xml</li>
<li>data/</li>
<li>&nbsp;&gt;&nbsp;sql/</li>
<li>doc/</li>
<li><div style="float: right">[SF_CLASSES_DIR]</div>lib/</li>
<li>&nbsp;&gt;&nbsp;model/</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;om/</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;Base[OBJECT].php</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;Base[OBJECT]Peer.php</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;[OBJECT].php</li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;[OBJECT]Peer.php</li>
<li>log/</li>
<li>test/</li>
<li>&nbsp;&gt;&nbsp;sf/</li>
<li><div style="float: right">[SF_WEB_DIR]</div>web/</li>
<li>&nbsp;&gt;&nbsp;css/</li>
<li>&nbsp;&gt;&nbsp;images/</li>
<li>&nbsp;&gt;&nbsp;js/</li>
<li><div style="float: right">[SF_UPLOAD_DIR]</div>&nbsp;&gt;&nbsp;uploads/</li>
<li>&nbsp;&gt;&nbsp;index.php</li>
</ul>

</div>
</div>

<div class="minisubcol">
<h2>Constants</h2>
<div class="content">

<h3>Symfony</h3>
<ul>
<li><span class="method">SF_PROJECT</span></li>
<li><span class="method">SF_DEBUG</span></li>
<li><span class="method">SF_DEFAULT_CULTURE</span></li>
<li><span class="method">SF_TIMEOUT</span></li>
</ul>

<h3>Criteria</h3>
<ul>
<li><span class="method">EQUAL / NOT_EQUAL</span></li>
<li><span class="method">GREATER_THAN / LESS_THAN</span></li>
<li><span class="method">GREATER_EQUAL / LESS_EQUAL</span></li>
<li><span class="method">LIKE / NOT LIKE / ILIKE / NOT ILIKE</span></li>
<li><span class="method">IN / NOT IN</span></li>
</ul>

</div>
</div>

<!-- end column -->
</div>

<!--
TODO
* sf-gen, sf-admin
* Exemple rapide d'une template, d'un criterion
* Classes spécifiques : sfMail, sfPager, sfShoppingCart, sfThumbnail
//-->

<div style="clear: both">

<div class="footnote"></div>

</body>
</html>
